package com.itshare.video.util.mapping;

import com.itshare.video.pojo.dto.UserInfoDTO;
import com.itshare.video.pojo.po.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * userDTO  和 UserPO 的直接映射
 * @Author lyr
 * @create 2020/10/24 20:11
 */
@Mapper
public interface UserBeanMapping {

    /**
     * userDTO 转 user
     * @param userInfoDTO
     * @return
     */
    @Mappings({
            @Mapping(source = "avatar",target = "avatar"),
            @Mapping(source = "email",target = "email"),
            @Mapping(source = "userIntroduce",target = "userIntroduce"),
            @Mapping(source = "nickName",target = "nickname"),
            @Mapping(source = "userName",target = "userName")

    })
    User fromUserDTO(UserInfoDTO userInfoDTO);


    /**
     * user 转userDTO
     */
    @Mappings({
            @Mapping(source = "avatar",target = "avatar"),
            @Mapping(source = "email",target = "email"),
            @Mapping(source = "userIntroduce",target = "userIntroduce"),
            @Mapping(source = "nickname",target = "nickName"),
            @Mapping(source = "userName",target = "userName"),
            @Mapping(source = "roleId",target = "role")

    })
    UserInfoDTO fromUser(
            User user);

}
